<template>
  <view class="content">
    <view>home 首页</view>
    <navigator url="/pages/login/index">跳转到 login</navigator>
    <view>
      <view>翻译内容：{{ t('姓名') }}</view>
      <view>
        动态翻译内容：{{
          t('年龄{age}', {
            age: 18,
          })
        }}
      </view>
    </view>
    <view :style="{ color: count ? 'red' : '#000' }" @click="changeLang">
      切换语言{{ getLanguage() }}
    </view>
    <image class="fire" :src="fire" alt="" />
  </view>
</template>

<script setup lang="ts">
import { getLanguage, setLanguage, useLang } from 'i18n-use'
import { ref } from 'vue'

import fire from '@/assets/fire.png'

const count = ref(false)
const { t } = useLang('home')
const changeLang = () => {
  setLanguage(getLanguage() == 'zh' ? 'in' : 'zh')
  count.value = !count.value
}
</script>

<style>
.content {
  margin: 0 auto;
  width: 320px;
  height: 100vh;
  text-align: center
}

.fire {
  width: 400px;
  height: 400px;
}
</style>
